/* Copyright (c) 2004-2024 Peigen.info. All rights reserved. */

package info.peigen.hotpot.business.coupon.core.domain;

import cn.hutool.core.date.DateTime;
import cn.hutool.core.lang.Assert;
import cn.hutool.core.util.ObjectUtil;
import info.peigen.hotpot.common.core.lang.money.Money;
import info.peigen.hotpot.common.core.result.ResultCode;
import info.peigen.hotpot.common.service.base.exception.BusinessException;
import jakarta.validation.constraints.NotNull;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import lombok.experimental.FieldDefaults;
import lombok.experimental.SuperBuilder;

import java.util.List;

/**
 * <b>(CouponUseStrategy)</b>
 *
 * @author Peigen
 * @version 1.0.0
 * @since 2022/6/28
 */
@SuperBuilder
@Data
@NoArgsConstructor
@AllArgsConstructor
@FieldDefaults(level = AccessLevel.PRIVATE)
@Accessors(chain = true)
public class CouponUseStrategy {
    /** 可用日期 */
    DateTime     enableUseDate;
    /** 可用金额 */
    Money        enableUseAmount;
    List<String> enablePartners;
    /** 有效期 */
    @NotNull
    CouponExpiryDate expiryDate;

    public void check() {
        Assert.isTrue(ObjectUtil.isAllNotEmpty(enableUseDate, enableUseAmount, enablePartners),
                () -> new BusinessException(ResultCode.FAILURE, "enableUseDate, enableUseAmount, enablePartners 不得同时为空!"));
    }
}